<template>
    <div id="app">
        <button @click="c">connect</button>
        <button @click="sign">sign</button>
        <button @click="send">send</button>
        <div>{{dc}}</div>
    </div>
</template>

<script>
import mio, {
  addEventListener,
  connect,
  socket,
  sendToServer,
sendToServerReceive
} from "./util/mio.client";

export default {
  data() {
    return {
      name: "App",
      dc: "test"
    }
  },
  methods: {
    c() {
      //   this.socket = io.connect("http://localhost:15177");

      //   this.socket.on("connect", function() {
      //     console.log("connect");
      //   });
      //   this.socket.on("WebSocketPakcetEventName", function(packet) {
      //     console.log("WebSocketPakcetEventName");
      //     console.log(packet);
      //   });
      //   this.socket.on("disconnect", function() {
      //     console.log("disconnect");
      //   });
      addEventListener("chat", (socket, data) => {
        console.log(data.content);
        this.dc = data.content + "";
        console.log("set complete");
      });
      connect("http://localhost:15177");
    },
    send() {
      var c = {
        content: "hello world I am web client"
      };
      sendToServer("chat", c);
    },
    sign(){
         var s={
             clientType:6,
             roomId:0,
             meetorId:0,
             token:'',
         }
        sendToServerReceive("reqSign",s,"respSign").then(data=>{
            console.log(data);
        }).catch(error=>{
            console.log(error);
        });
        
    }
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
